package com.hf.wujian.dispatch.imp;

import com.hf.wujian.annotation.Dispatch;
import com.hf.wujian.constant.Command;
import com.hf.wujian.dispatch.BSHDispatch;
import com.hf.wujian.model.GameHall;
import com.hf.wujian.model.GameUser;
import com.hf.wujian.netty.NettyMsg;
import io.netty.channel.ChannelHandlerContext;
import java.util.List;

/**
 * 获得房间房间名调度类
 *
 * @author hf
 * @date 2018/11/27
 * @version 1.0
 *
 */
@Dispatch(command = Command.COMMAND_GET_ROOMS)
public class GetRoomsDispatch implements BSHDispatch {
    @Override
    public void dispatch(ChannelHandlerContext ctx, NettyMsg nettyMsg, GameHall gameHall, GameUser gameUser) {
        StringBuffer stringBuffer = new StringBuffer();
        List<String> rooms = gameHall.getGameRooms();
        for (String room : rooms) {
            stringBuffer.append(room + ",");
        }
        ctx.writeAndFlush(stringBuffer.toString() + "\r\n");
    }
}
